package com.tanggh.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.tanggh.entity.JobCategory;
import com.tanggh.service.JobCategoryService;
import com.tanggh.util.TemplateUtils;
import com.tanggh.util.Tools;

public class JobCategoryAction extends GenericAction{

	@Autowired
	private JobCategoryService jobCategoryService;
	
	@Override
	public String execute() throws Exception {
		String method = Tools.toTrim(getString("method"));
		if("createJobCategory".equals(method)) {
			return createJobCategory();
		}
		if("createPublishJobCategory".equals(method)) {
			return createPublishJobCategory();
		}
		List<JobCategory> list = jobCategoryService.listAll();
		TemplateUtils.createJobCategory(list);
		return null;
	}
	
	
	private String createPublishJobCategory() throws Exception { //生成发布信息的行业分类
		List<JobCategory> list = jobCategoryService.listAll();
		TemplateUtils.createPublishJobCategory(list);
		return null;
	}
	
	private String createJobCategory() throws Exception {
		List<JobCategory> list = jobCategoryService.getCategoryByCode("22"); //全职招聘求职 Code 2200
		for(JobCategory j : list) {
			System.out.println(j.getName());
		}
		return null;
	}
}
